package com.longrou.base.fragment

import android.databinding.DataBindingUtil
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.gson.Gson
import com.google.gson.internal.LinkedTreeMap
import com.longrou.base.R
import com.longrou.base.base.BaseFragment
import com.longrou.base.base.BaseResult
import com.longrou.base.databinding.FragmentHomeBinding
import com.longrou.base.repository.http.TestMo
import com.longrou.base.repository.http.TestModel
import com.longrou.base.util.ToastUtils.Companion.showToast
import com.zhouyou.http.callback.SimpleCallBack
import com.zhouyou.http.exception.ApiException
import com.zhouyou.http.EasyHttp
import com.zhouyou.http.callback.CallBackProxy
import com.zhouyou.http.callback.ProgressDialogCallBack


/**
 * @Description:
 * @Author: LongRou
 * @CreateDate: 2018-05-18 23:20
 * @Version: 1.0
 **/
class HomeFragment : BaseFragment() {
    var binding : FragmentHomeBinding? = null
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = DataBindingUtil.inflate<FragmentHomeBinding>(inflater, R.layout.fragment_home, container, false)
        init()
        return binding!!.root
    }
    fun init(){
        binding?.click = this;

    }
    fun httpTest(){
        Log.e("LONGROU", "httpTest - httpTest")
        //模型接收
        TestModel.testHttp("android_desc")
                .execute(object : SimpleCallBack<TestMo>(){
                    override fun onSuccess(t: TestMo?) {
                        //showToast(context,t.toString())
                        Log.e("test1",t?.toString())
                    }

                    override fun onError(e: ApiException?) {
                        showToast(context,e?.message)
                    }
                })
        //String接收整个body
        TestModel.testHttp("android_desc")
                .execute(object : SimpleCallBack<String>(){
                    override fun onSuccess(t: String?) {
                        //showToast(context,t)
                        Log.e("test2",t)
                    }

                    override fun onError(e: ApiException?) {
                        showToast(context,e?.message)
                    }
                })


    }
}